// 支付结果

<template>
  <view>
    <!-- 结果 -->
    <view class="result-box">
      <view class="result-title">
        <text class="iconfont icon-duigou1"></text>
        <text class="text">生成订货单</text>
      </view>
      <view class="result-tip">请耐心等待审核</view>
      <view class="result-btn">
        <view class="btn" @tap="toHome">返回首页</view>
        <view class="btn" @tap="toOrder">查看订单</view>
      </view>
    </view>
    <!-- 推荐 -->
    <view class="recommend-box">
      <view class="goods-item" @tap="getDetail(item.id)" v-for="item in goodsList" :key="item.id">
        <view class="goods-img">
          <image :src="item.goods_image" />
        </view>
        <view class="goods-bottom">
          <view class="goods-title">{{ item.goods_name }}</view>
          <view class="goods-btn">
            <view class="money">
              <view class="money-box" v-if="item.price !== '' && priceStatus">
                <text class="price1">￥</text>
                <text class="price2">{{ item.price }}</text>
                <text class="digit">.{{ item.decimal }}</text>
              </view>
            </view>
            <view class="t-icon t-icon-a-" @tap.stop="showPop(item)"></view>
          </view>
        </view>
      </view>
    </view>
    <!-- 选择规格弹出框 -->
    <pop-choose :goods="goods" v-model="show"></pop-choose>
  </view>
</template>

<script>
import { mapState } from 'vuex'

export default {
  data() {
    return {
      goodsList: [],
      show: false,
      goods: {}
    }
  },
  onLoad(options) {
    this.getGoods()
  },
  methods: {
    getDetail(id) {
      uni.navigateTo({ url: `/pages/home/homeGoods/goodsDetail?id=${id}` })
    },
    // 弹出框
    showPop(goods) {
      this.goods = goods
      this.show = true
    },
    // 获取商品
    async getGoods() {
      const res = await this.$http.post('/api/kuyou/order/index/goodsGoodsList', {
        tag: 'sale',
        page: this.page
      })
      if (res.code == 200) {
        if (res.data.list.length === 0) {
          this.hasMore = false
        }
        res.data.list.forEach((item) => {
          item.goods_image = item.goods_image.startsWith('http')
            ? item.goods_image
            : this.$baseURL + item.goods_image
        })
        this.goodsList = [...this.goodsList, ...res.data.list]
      }
    },
    toHome() {
      uni.switchTab({ url: '/pages/home/index' })
    },
    toOrder() {
      uni.navigateTo({ url: '/pages/my/order/index?current=0' })
    },
    addGoods() {}
  },
  computed: {
    ...mapState(['priceStatus'])
  }
}
</script>

<style>
page {
  padding-bottom: 60rpx;
  background-color: #f7f7f7;
}
</style>
<style lang="scss" scoped>
.page {
}

// 结果
.result-box {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 750rpx;
  height: 312rpx;
  background: linear-gradient(126deg, #ff6d32 0%, #fe3d23 100%);
  color: #fff;
  .result-title {
    font-size: 48rpx;
    .iconfont {
      margin-right: 16rpx;
      font-size: 48rpx;
    }
    .text {
      font-weight: 500;
    }
  }
  .result-tip {
    margin: 20rpx 0 40rpx;
    font-size: 24rpx;
    font-weight: 500;
  }
  .result-btn {
    display: flex;
    .btn {
      display: flex;
      justify-content: center;
      align-items: center;
      margin: 0 40rpx;
      width: 200rpx;
      height: 60rpx;
      border-radius: 50rpx;
      border: 1px solid #ffffff;
      font-weight: 500;
    }
  }
}

// 推荐
.recommend-box {
  display: flex;
  flex-wrap: wrap;
  padding: 0 24rpx;
  .goods-item {
    margin-top: 20rpx;
    width: 340rpx;
    height: 540rpx;
    background: #ffffff;
    border-radius: 12rpx;
    &:nth-child(odd) {
      margin-right: 22rpx;
    }
    .goods-img {
      image {
        width: 340rpx;
        height: 340rpx;
        // background: #d8d8d8;
        border-radius: 12rpx;
      }
    }
    .goods-bottom {
      margin-top: 14rpx;
      display: flex;
      justify-content: space-between;
      // align-items: center;
      flex-direction: column;
      width: 100%;
      height: 160rpx;
      .goods-title {
        padding: 0 20rpx;
        font-weight: 500;
        color: #111111;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
      }
      .goods-btn {
        padding: 0 20rpx;
        width: 100%;
        // margin-top: 40rpx;
        // padding-right: 24rpx;
        // text-align: right;
        margin-right: 24rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 46rpx;
        .money {
          .money-box {
            // display: flex;
            // justify-content: center;
            // align-items: center;
            .price1 {
              font-size: 20rpx;
              color: #fe3d23;
              font-weight: 600;
            }
            .price2 {
              font-size: 24rpx;
              color: #fe3d23;
              font-weight: 600;
            }
            .digit {
              font-size: 20rpx;
              color: #fe3d23;
              font-weight: 600;
            }
          }
        }
        .t-icon {
          width: 44rpx;
          height: 44rpx;
        }
      }
    }
  }
}
</style>

